package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.Result;
import com.itheima.service.HealthReportService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/report")
public class HealthReportController {

    @Reference
    private HealthReportService healthReportService;

    @RequestMapping("/FindHealthReport")
    public Result FindHealthReport(Integer id,HttpServletRequest request){
        Cookie[] cookies = request.getCookies();
        String telephone = null;
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals("login_member_telephone")){
                telephone = cookie.getValue();
            }
        }
        Result result = healthReportService.FindHealthReport(id,telephone);
        return result;
    }
}
